import type {
    CascaderTypeDetailResult,
    CascaderTypeEntityReq,
    CascaderTypeListResult,
    CascaderTypePageReq,
} from "@/api/types";
import request from "@/utils/http";

/** 新增级联字典项 */
function create(data: CascaderTypeEntityReq): Promise<Resp<string>> {
    return request({
        url: "/sys/cascaderType/create",
        method: "post",
        data,
    });
}

/** 删除级联字典 */
function remove(id: string): Promise<Resp<null>> {
    return request({
        url: "/sys/cascaderType/remove",
        method: "post",
        data: { id },
    });
}

/** 修改级联字典 */
function update(data: CascaderTypeEntityReq): Promise<Resp<null>> {
    return request({
        url: "/sys/cascaderType/update",
        method: "post",
        data,
    });
}

/** 根据 id 查询级联字典 */
function findById(id: string): Promise<Resp<CascaderTypeDetailResult>> {
    return request({
        url: "/sys/cascaderType/findById",
        method: "get",
        params: { id },
    });
}

/** 获取级联字典分页列表 */
function page(data: CascaderTypePageReq): Promise<Resp<CascaderTypeListResult[]>> {
    return request({
        url: "/sys/cascaderType/page",
        method: "post",
        data,
    });
}

export const cascaderTypeApi = {
    create,
    remove,
    update,
    findById,
    page,
};
